package cn.edu.neu.softlab633.influencemaximization.sy.M_TLTGreedy;

import cn.edu.neu.softlab633.influencemaximization.sy.bean.CELF.CELFQueue;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.CELF.CELFQueueEle;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.Graph;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.MarginGain;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.Potentiality;
import cn.edu.neu.softlab633.influencemaximization.sy.model.lt.LinearThresholdModel;

import java.util.ArrayList;

/**
 * Created by Jason on 2017/5/11.
 */
public class M_Candidate {
    public static CELFQueue getCandidate(int k, int p, double threshold, Double[] query, ArrayList<Potentiality> potentialities, Graph graph) {
        int num = (int) (Math.pow(2, p) * k);
        CELFQueue celfQueue = new CELFQueue();
        int top = potentialities.size();
        for (int i = 0; i < num && i < top; i++) {
            int id = potentialities.get(0).getId();
            ArrayList<Integer> originalSet = new ArrayList<>();
            originalSet.add(id);
            MarginGain marginGain = LinearThresholdModel.influencePropagation(threshold, query, originalSet, graph);
            celfQueue.add(new CELFQueueEle(id, marginGain, 1));
            potentialities.remove(0);
        }
        return celfQueue;
    }
}
